Skip to content

feat: typed MCP returns, async MCP client, error parity, forward-compat models#20

Merged
KhaledSalhab-Develeap merged 2 commits into
mainfrom
feat/mcp-typed-models
Apr 20, 2026
Merged

feat: typed MCP returns, async MCP client, error parity, forward-compat models#20
KhaledSalhab-Develeap merged 2 commits into
mainfrom
feat/mcp-typed-models

Conversation

@KhaledSalhab-Develeap
Copy link
Copy Markdown
Collaborator

Summary

Upgrades the MCP client from returning raw dicts to returning typed Pydantic models, matching the REST client's contract. Adds async MCP client, error handling parity, retry logic, and forward-compatible models.

Typed returns

  • All 16 MCP methods now return Pydantic models (was Any)
  • New models: TimeGroup, ResponseTimeReport, AlertHistory, MttrReport, MttaReport, MonitorMetricsSummary, ProbeLogResponse, TeamMember, OutageMonitorSummary
  • OutageTimeline.outage is typed Outage, .monitor is OutageMonitorSummary (was dict[str, Any])
  • All models verified against live MCP API

Async MCP client

  • AsyncMcpTransport with httpx.AsyncClient, asyncio.Lock, async retry
  • AsyncHyperpingMcpClient with identical method signatures and return types as sync

Error handling parity

  • Both transports now map 404/429/400/422 to the same exception types as the REST client
  • Retry with exponential backoff on 500/502/503/504

Forward compatibility

  • All 28 response models changed from extra="ignore" to extra="allow"
  • New API fields preserved instead of silently dropped (matches Stripe/OpenAI SDK practice)

Thread safety

  • threading.Lock (sync) and asyncio.Lock (async) on request ID counter and init flag

Test plan

  • 331 tests pass, ruff clean, mypy clean
  • Live API: all 16 typed returns verified
  • Live API: OutageTimeline.outage.uuid, .monitor.name typed access works
  • Live API: 403 raises HyperpingAuthError

…at models

MCP client now returns Pydantic models instead of raw dicts, matching
the REST client's contract. Models updated to match verified API shapes.

Typed returns:
- All 16 MCP methods return Pydantic models (StatusSummary, MttrReport,
  MonitorAnomaly, OutageTimeline, TeamMember, etc.)
- New models: TimeGroup, ResponseTimeReport, AlertHistory, MttrReport,
  MttaReport, MonitorMetricsSummary, ProbeLogResponse, TeamMember,
  OutageMonitorSummary
- OutageTimeline.outage is now typed Outage, .monitor is OutageMonitorSummary

Async MCP client:
- AsyncMcpTransport with httpx.AsyncClient, asyncio.Lock, async retry
- AsyncHyperpingMcpClient with identical API to sync version

Error handling parity:
- Both sync and async MCP transports map 404, 429, 400/422 to the same
  exception types as the REST client
- Retry with exponential backoff on 500/502/503/504

Forward compatibility:
- All response models changed from extra="ignore" to extra="allow"
- New API fields are preserved instead of silently dropped

Thread safety:
- threading.Lock (sync) and asyncio.Lock (async) on request ID counter
  and initialization flag
Add 83 new tests across 5 test files. Every source file is now at 87%
or above (lowest: 88%). Overall coverage: 94% -> 96%.

New test files:
- test_async_mcp_transport.py (19 tests): full async transport coverage
- test_client_coverage.py (20 tests): client retry, ping, repr, errors

Extended test files:
- test_mcp_transport.py (+11 tests): 404, 429, 400/422, retry exhaustion
- test_async_preexisting.py (+13 tests): async maintenance and outage ops
- test_sdk_surface.py (+5 tests): protocol bases, model deprecation aliases
- test_outages.py (+8 tests): sync unacknowledge, delete, create, get
@KhaledSalhab-Develeap KhaledSalhab-Develeap merged commit 1c3ef51 into main Apr 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant